From 1767af80338b576af746a09f31ded2dc508e100a Mon Sep 17 00:00:00 2001 From: oliskoli Date: Thu, 28 Jun 2007 22:12:45 +0000 Subject: [PATCH] Add field separator to "pretty_deg_format". --- defs.h | 2 +- garmin_gpi.c | 2 +- html.c | 4 ++-- text.c | 4 ++-- util.c | 16 +++++++++------- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/defs.h b/defs.h index 92057a607..1dffa3e8f 100644 --- a/defs.h +++ b/defs.h @@ -770,7 +770,7 @@ char * strip_html(const utf_string*); char * strip_nastyhtml(const char * in); char * convert_human_date_format(const char *human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */ char * convert_human_time_format(const char *human_timef); /* "HH+mm+ss" -> "%H+%M+%S" */ -char * pretty_deg_format(double lat, double lon, char fmt, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ +char * pretty_deg_format(double lat, double lon, char fmt, char *sep, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ char * get_filename(const char *fname); /* extract the filename portion */ diff --git a/garmin_gpi.c b/garmin_gpi.c index 3d36c816c..cdd6d4aae 100644 --- a/garmin_gpi.c +++ b/garmin_gpi.c @@ -640,7 +640,7 @@ wdata_compute_size(writer_data_t *data) str = xstrdup(wpt->notes); } else if (opt_pos) - str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', 0); + str = pretty_deg_format(wpt->latitude, wpt->longitude, 's', " ", 0); if (str) { /* this will be stored into street-address field */ res += 22 + strlen(str); diff --git a/html.c b/html.c index fa4abb7b8..3b2ac1329 100644 --- a/html.c +++ b/html.c @@ -89,7 +89,7 @@ html_disp(const waypoint *wpt) gbfprintf(file_out, "\n
\n", wpt->shortname); gbfprintf(file_out, "\n"); gbfprintf(file_out, "

%s - ",(global_opts.synthesize_shortnames) ? mkshort_from_wpt(mkshort_handle, wpt) : wpt->shortname); - cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 1); + cout = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 1); gbfprintf(file_out, "%s (%d%c %6.0f %7.0f)", cout, utmz, utmzc, utme, utmn); xfree (cout); if (wpt->altitude != unknown_alt) @@ -199,7 +199,7 @@ html_disp(const waypoint *wpt) if ( coordstr ) { lon = atof( coordstr ); } - coordstr = pretty_deg_format(lat, lon, degformat[2], 1); + coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 1); gbfprintf( file_out, "%s
\n", coordstr ); diff --git a/text.c b/text.c index 5bf59ae3f..a8a3a2efa 100644 --- a/text.c +++ b/text.c @@ -91,7 +91,7 @@ text_disp(const waypoint *wpt) tm = time(NULL); strftime(tbuf, sizeof(tbuf), "%d-%b-%Y", localtime(&tm)); - tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], 0); + tmpout1 = pretty_deg_format(wpt->latitude, wpt->longitude, degformat[2], " ", 0); if (wpt->altitude != unknown_alt) { xasprintf(&altout, " alt:%d", (int) ( (altunits[0]=='f')?METERS_TO_FEET(wpt->altitude):wpt->altitude) ); } @@ -193,7 +193,7 @@ text_disp(const waypoint *wpt) if ( coordstr ) { lon = atof( coordstr ); } - coordstr = pretty_deg_format(lat, lon, degformat[2], 0); + coordstr = pretty_deg_format(lat, lon, degformat[2], " ", 0); gbfprintf( file_out, "%s\n", coordstr); xfree(coordstr); } diff --git a/util.c b/util.c index 225fe65fa..826308463 100644 --- a/util.c +++ b/util.c @@ -1394,10 +1394,11 @@ convert_human_time_format(const char *human_timef) * Return a decimal degree pair as * DD.DDDDD DD MM.MMM or DD MM SS.S * fmt = ['d', 'm', 's'] + * sep = string between lat and lon (separator) * html = 1 for html output otherwise text */ char * -pretty_deg_format(double lat, double lon, char fmt, int html) +pretty_deg_format(double lat, double lon, char fmt, char *sep, int html) { double latmin, lonmin, latsec, lonsec; int latint, lonint; @@ -1411,19 +1412,20 @@ pretty_deg_format(double lat, double lon, char fmt, int html) lonmin = 60.0 * (fabs(lon) - lonint); latsec = 60.0 * (latmin - floor(latmin)); lonsec = 60.0 * (lonmin - floor(lonmin)); + if (sep == NULL) sep = " "; /* default " " */ if (fmt == 'd') { /* ddd */ - xasprintf ( &result, "%c%6.5f%s %c%6.5f%s", - latsig, fabs(lat), html?"°":"", + xasprintf ( &result, "%c%6.5f%s%s%c%6.5f%s", + latsig, fabs(lat), html?"°":"", sep, lonsig, fabs(lon), html?"°":"" ); } else if (fmt == 's') { /* dms */ - xasprintf ( &result, "%c%d%s%02d'%04.1f\" %c%d%s%02d'%04.1f\"", - latsig, latint, html?"°":" ", (int)latmin, latsec, + xasprintf ( &result, "%c%d%s%02d'%04.1f\"%s%c%d%s%02d'%04.1f\"", + latsig, latint, html?"°":" ", (int)latmin, latsec, sep, lonsig, lonint, html?"°":" ", (int)lonmin, lonsec); } else { /* default dmm */ - xasprintf ( &result, "%c%d%s%06.3f %c%d%s%06.3f", - latsig, latint, html?"°":" ", latmin, + xasprintf ( &result, "%c%d%s%06.3f%s%c%d%s%06.3f", + latsig, latint, html?"°":" ", latmin, sep, lonsig, lonint, html?"°":" ", lonmin); } return result; -- 2.30.2